<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
    <style>
        .one,.two,.three,.four{
            border: 1px solid #333;
            padding: 5px;
            margin: 5px;
        }
    </style>
</head>
<body>
    <div id="app">
        <com-a :a="a" :b="b"></com-a>
    </div>
</body>
<script>
  
    var comD = {
        props:["a","b"],
        data(){
            return {

            }
        },
        template:`<div class="one">
            <p>这是组件d</p>
            </div>`,
        mounted() {
            console.log("组件D",this.a,this.b);
        },
    }

    var comC = {
        props:["a","b"],
        data(){
            return {

            }
        },
        template:`<div class="one">
            <p>这是组件C</p>
            <com-d :a="a" :b="b"></com-d>
        </div>`,
        components:{
            comD:comD,
        }
    }

    var comB = {
        props:["a","b"],
        data(){
            return {

            }
        },
        template:`<div class="one">
            <p>这是组件B</p>
            <com-c :a="a" :b="b"></com-c>
        </div>`,
        components:{
            comC:comC,
        }
    }

    var comA = {
        props:["a","b"],
        data(){
            return {

            }
        },
        template:`<div class="one">
                <p>这是组件A</p>
                <com-b :a="a" :b="b"></com-b>
        </div>`,
        components:{
            comB:comB,
        }
    }

   


    // 根实例/组件/应用
    var vm = new Vue({
        el:"#app",
        data:{
            a:1,
            b:2,
        },
        components:{ // 在当前组件(根组件) 注册了两个子组件 (comA comB)
            // 键名 => 组件名
            // 键值 => 组件的配置对象 
            comA:comA,
        }
    })



</script>
</html>